import request from '@/utils/request';

/**
 * 分页查询报关
 */
export async function pageApplyCustoms(params) {
  const res = await request.get('/order/applyCustoms/page', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询报关列表
 */
export async function listApplyCustoms(params) {
  const res = await request.get('/order/applyCustoms', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询报关
 */
export async function getApplyCustoms(id) {
  const res = await request.get('/order/applyCustoms/' + id);
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加报关
 */
export async function addApplyCustoms(data) {
  const res = await request.post('/order/applyCustoms', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改报关
 */
export async function updateApplyCustoms(data) {
  const res = await request.put('/order/applyCustoms', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除报关
 */
export async function removeApplyCustoms(id) {
  const res = await request.delete('/order/applyCustoms/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
